package cn.wolfcode.luowowo.shop.domain;

import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.common.domain.BaseDomain;
import cn.wolfcode.luowowo.member.domain.UserInfo;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * 物品详情
 */
@Setter
@Getter
public class ShopDetail extends BaseDomain{
    public static final boolean  ABROAD_NO = false;  //国内
    public static final boolean  ABROAD_YES = true;  //国外

    public static final int STATE_NORMAL = 0;  //正常
    public static final int STATE_PUBLISH = 1; //发布

    private ShopStrategy shopStrategy;//物品归类上级叫什么

    private Destination dest;//归属地

    private ShopStrategyTheme theme;//主题id

    private UserInfo author;//销售者

    private String title;//物品标题名

    private String info;//物品简介

    private String coverUrl;//背景图

    private String ref;//码数

    private String[] refies;//对码数传递做处理

    private Integer integral;//积分价

    private Integer price;//价格

    private Date createTime;//创建时间

    private Boolean isabroad;//是否外国

    private Integer viewnum;//阅读数

    private Integer replynum;//评论数

    private Integer favornum;//收藏数

    private Integer sharenum;//分享数

    private Integer thumbsupnum;//点赞数

    private Integer state;//状态

    private Integer sellsun;//销售量

    private ShopContent shopContent;

    //添加编辑时，前端传入是long数组， 数据库保存的是id拼接的字符串
    public String getRef(){
        //id1,id2,id3
        return StringUtils.join(refies, ",");
    }
    //从数据库拿出的id拼接字符串转换成数组
    public String[] getRefIds(){
            String[] strs = ref.split(",");
        return strs;
    }

    public String getStateDisplay(){
        return state == STATE_PUBLISH ? "发布" :"正常";
    }
}